Skip to content

Conversation

hjr265
Copy link
Contributor

@hjr265 hjr265 commented Jul 28, 2025

Let's say I am running this LSP server with Ruff (for linting) and Jedi (for autocompletion, with eager off). I then open a notebook document with a few cells in it.

I open the document (and the cells) with the notebookDocument/didOpen method.

Now, I request completion using the method textDocument/completion and receive the completion items as expected.

So far, so good.

Now, if I attempt to resolve one of the completion items using the completionItem/resolve method, I receive an empty array as a result.

This issue occurs because PyLSP concatenates cells of notebook documents into a temporary document and then uses it to generate completion items. That temporary document has a "randomly" generated UUID as its URI. When generating completion items, the shared data "LAST_JEDI_COMPLETIONS" is stored on this temporary document.

However, when the client sends back any "completion item" to be resolved, it looks for "LAST_JEDI_COMPLETIONS" shared data on the actual cell document, where this shared data is not present, and the request to "resolve" fails.

This PR copies the "LAST_JEDI_COMPLETIONS" shared data from the temporary document to the cell document at the end of the "completion" request.

@ccordoba12 ccordoba12 changed the title Copy LAST_JEDI_COMPLETIONS to cell document so that completionItem/resolve will work Copy LAST_JEDI_COMPLETIONS to cell document so that completionItem/resolve will work Jul 30, 2025
@ccordoba12
Copy link
Member

Thanks @hjr265 for your contribution! It looks good to me, but I'd like @krassowski to review it because this could impact JupyterLab-LSP.

@ccordoba12 ccordoba12 added this to the v1.13.1 milestone Jul 30, 2025
@ccordoba12 ccordoba12 added the bug Something isn't working label Jul 30, 2025
@krassowski
Copy link
Member

No objections from my side - looks like fine workaround, though I would also suggest adding a test in case if it needs to be reworked later on.

@hjr265
Copy link
Contributor Author

hjr265 commented Aug 4, 2025

Thanks @krassowski!

Let me add a test for this.

@hjr265
Copy link
Contributor Author

hjr265 commented Aug 7, 2025

@ccordoba12 I have added a test. Please let me know if there is anything else.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @hjr265!

@ccordoba12 ccordoba12 merged commit 5c8cfac into python-lsp:develop Aug 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants